﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MKAdminCore.ToolKit.RegexHelper
{
    public static class RegexMatchPattern
    {
        /// <summary>
        /// 纯字母或数字
        /// </summary>
        public static string LetterNum = "^[0-9a-zA-Z]+$";
        /// <summary>
        /// 纯数字
        /// </summary>
        public static string NumOnly = "^[0-9]+$";
        /// <summary>
        /// 邮箱地址
        /// </summary>
        public static string Email = "^[\\w.]+@\\w{2,5}.com+$";
        /// <summary>
        /// 手机号
        /// </summary>
        public static string MobilePhone = "^[1][3,4,5,7,8,9][0-9]{9}$";
        /// <summary>
        /// 链接地址
        /// </summary>
        public static string Link = "(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]";


        public static string GetMatchPattern(string patternStr)
        {
            var matchPattern = "";
            switch (patternStr)
            {
                case "LetterNum":
                    matchPattern = LetterNum;
                    break;
                case "NumOnly":
                    matchPattern = NumOnly;
                    break;
                case "Email":
                    matchPattern = Email;
                    break;
                case "MobilePhone":
                    matchPattern = MobilePhone;
                    break;
                case "Link":
                    matchPattern = Link;
                    break;
                default:
                    break;
            }
            return matchPattern;

        }
    }

}
